package com.sskj.level.ui.activity;

import android.content.Context;
import android.content.Intent;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;

import com.alibaba.android.arouter.launcher.ARouter;
import com.sskj.level.R;
import com.sskj.lib.Constans;
import com.sskj.lib.RConfig;
import com.sskj.lib.base.BaseActivity;

public class LevelActivity extends BaseActivity<LevelActivityPresenter> {

    @Override
    protected int getLayoutResId() {
        return R.layout.level_activity;
    }

    @Override
    public LevelActivityPresenter getPresenter() {
        return new LevelActivityPresenter();
    }

    @Override
    protected void initView() {
        String code = getIntent().getStringExtra(Constans.CODE);
        if (TextUtils.isEmpty(code)) {
            code = "USDT";
        }
        Fragment fragment = (Fragment) ARouter.getInstance().build(RConfig.LEVEL_FRAGMENT_MAIN).withString(Constans.CODE, code).navigation();
        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        fragmentTransaction.add(R.id.frameLayout, fragment);
        fragmentTransaction.show(fragment);
        fragmentTransaction.commitNow();
    }

    public static void start(Context context, String code) {
        Intent intent = new Intent(context, LevelActivity.class);
        intent.putExtra(Constans.CODE, code);
        context.startActivity(intent);
    }
}
